package com.lq.memo.entity;

import lombok.Data;

import java.util.HashMap;

/**
 * @ClassName MyResponse
 * @Description
 * @Author LQ
 * @Date 2021/11/14 17:48
 * @Version 1.0
 */
@Data
public class MyResponse extends HashMap<String, Object> {

    public static final Integer SUCCESS_CODE = 200;
    public static final Integer FAIL_CODE = -1;

    private Integer code = 200;

    public MyResponse message(String message) {
        this.put("message", message);
        return this;
    }

    public MyResponse success() {
        this.put("code", SUCCESS_CODE);
        return this;
    }

    public MyResponse fail() {
        this.put("code", FAIL_CODE);
        return this;
    }
    public MyResponse data(Object data) {
        this.put("data", data);
        return this;
    }

    @Override
    public MyResponse put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public String getMessage() {
        return String.valueOf(this.get("message"));
    }

    public Object getData() {
        return this.get("data");
    }
}
